Open
Conversation
Member
|
Normalement, tu peux aussi utiliser la syntaxe: |
Member
|
Pour information, j‘avais eu justement un besoin similaire pour
configurer redis pour l‘environnement de développement pour les containers:
https://github.com/linuxfrorg/linuxfr.org/blob/0f970f466c01307e145a9c5d362b50539851cfa4/deployment/default.env#L5-L9
```env
# Redis service is used as a caching service and a publish/subscribe service
# to allow the different LinuxFr tools work together
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_URL=redis://redis:6379/0
```
C‘est ensuite utilisé dans la ligne de commande pour démarrer le service
`img-Linuxfr.org`:
https://github.com/linuxfrorg/linuxfr.org/blob/0f970f466c01307e145a9c5d362b50539851cfa4/deployment/linuxfr-img/Dockerfile#L51
```dockerfile
CMD ["sh", "-c", "exec ./img-LinuxFr.org -a 0.0.0.0:8000 -r
\"${REDIS_URL##redis://}\""]
```
C‘est aussi utilisé pour `board`, il faut lui partager les 2 variables
d'environnement (`REDIS_HOST` et `REDIS_PORT`):
https://github.com/linuxfrorg/board-sse-linuxfr.org/blob/43959c1712c87baa8baba34a48466099ac6ca13b/lib/board-sse-linuxfr.org/redis_plugin.rb#L15
```ruby
@redis = Redis.new(host: ENV['REDIS_HOST'] || "localhost", port:
ENV['REDIS_PORT'] || 6379)
```
Dans cette PR, on pourrait peut être ajouter une note sur les service
`img-LinuxFr.org` et `board` qui doivent être connectés au même service
Redis pour qu'ils interagissent correctement avec LinuxFr.
Enfin, dans la branche pour Rails 8, nous avons le fichier
`config/cable.yml` qui utilise aussi cette variable, mais je ne sais pas
à quoi ça correspond:
https://github.com/linuxfrorg/linuxfr.org/blob/07d30220aa598ac2bd2f242d816bf1b7b1d0c32e/config/cable.yml#L9
```yml
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
```
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Actuellement redis est dans un conteneur différent de la partie RoR (sur le même hôte). Il y a donc besoin de surcharger la configuration pour ce redis qui n'est pas sur 127.0.0.1 / localhost. Par contre on ne fait rien niveau authentification ou support TLS, donc à réserver à un réseau local...
Les REDIS_HOST/PORT/URL semblent être des variables standards. Le REDIS_CACHE_URL est spécifique à la configuration de notre CMS.